package es.unileon.prg2.censo.handler;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import es.unileon.prg2.censo.exception.CensoException;

/**
 * @author Manuel Molinos Crespo, Adrian Campazas Vega, Alberto Castro Delgado, Pedro Alvarez Alvarez, Adrian Cabello Galvan, Jose Alvaro Fernandez Alvarez
 *
 */

public class GenericId implements Handler {
	static Logger logger = Logger.getLogger(GenericId.class.getName());
	private String id;
	
	/**
	 * Constructor used for created the ID of the components without restrictions.
	 * @param id String composite for all type of characters and undefined size
	 */
	public GenericId(String id) {
		PropertyConfigurator.configure("etc/log4j.properties");
		this.id = id;
		logger.info(id+" created successfully");
	}
	
	/**
	 * Other constructor used for created the ID of the components without restrictions from a Handler parameter.
	 * @param id Handler composite for all type of characters and undefined size
	 */
	public GenericId(Handler id) {
		this.id = id.toString();
	}

	@Override
	public int compareTo(Handler another) {
		return this.id.compareTo(another.toString());
	}
	
	@Override
	public String toString() {
		return this.id;
	}
	
}
